package net.gz01.wallet.web.config;

import net.gz01.wallet.common.ZOIDGenerate;

import java.util.Random;

public class FDDConfig {
    public final static String islocalTest = SystemConfig.channelConfig.get("islocal_test");
    public final static String fddappid= SystemConfig.channelConfig.get("fddapp_id");
    public final static String fddapp_secret = getKey("fddapp_secret");
    public final static String fddcustomer_id = getKey("fddcustomer_id");
    public final static String fddhost_url = getKey("fddhost_url");
    public final static String fdd_V = "2.0";
    public final static  String APP_ID = fddappid;
    public final static  String APP_SECRET = fddapp_secret;
    public final static  String V = fdd_V;
    public final static  String HOST = fddhost_url;

    public final static String fddaccount_register = fddhost_url + getKey("fddaccount_register");//注册账号
    public final static String fddget_company_verify_url = fddhost_url + getKey("fddget_company_verify_url");
    public final static String fddget_person_verify_url = fddhost_url + getKey("fddget_person_verify_url");
    public final static String fddapply_cert = fddhost_url + getKey("fddapply_cert");

    public final static String fddapply_numcert = fddhost_url + getKey("fddapply_numcert");
    public final static String fddadd_signature = fddhost_url + getKey("fddadd_signature");
    public final static String fddcustom_signature = fddhost_url + getKey("fddcustom_signature");
    public final static String fdduploaddocs = fddhost_url + getKey("fdduploaddocs");
    public final static String fdduploadtemplate = fddhost_url + getKey("fdduploadtemplate");

    public final static String fddgenerate_contract = fddhost_url + getKey("fddgenerate_contract");
    public final static String fddextsign_auto = fddhost_url + getKey("fddextsign_auto");
    public final static String fddextsign = fddhost_url + getKey("fddextsign");
    public final static String fddviewContract = fddhost_url + getKey("fddviewContract");
    public final static String fdddownLoadContract = fddhost_url + getKey("fdddownLoadContract");

    public final static String fddcontractFiling = fddhost_url + getKey("fddcontractFiling");
    public final static String fddfind_personCertInfo = fddhost_url + getKey("fddfind_personCertInfo");
    public final static String fddfind_companyCertInfo = fddhost_url + getKey("fddfind_companyCertInfo");


    public final static String fdd_notify_url_verify = "" + getKey("fdd_notify_url_verify");//实名认证异步回调
    public final static String fdd_notify_url_sign = "" + getKey("fdd_notify_url_sign");//签署结果异步通知规范

    public final static String fdd_return_url_verify = getKey("fdd_return_url_verify");//实名认证同步回调
    public final static String fdd_return_url_sign = getKey("fdd_return_url_sign");

    public final static String fdd_hetong_url = getKey("fdd_hetong_url");//合同的查看的url

    private static String getKey(String key){
        if(!islocalTest.equals("1")) {
            switch (key) {
                case "fdd_notify_url_verify":
                case "fdd_notify_url_sign":
                case "fdd_return_url_verify":
                case "fdd_return_url_sign":
                    return SystemConfig.channelConfig.get(key+"_net");//获取外网服务器的 回调地址
            }
        }
        return SystemConfig.channelConfig.get(key);
    }


    public static String getSixNum(){
        Random random = new Random();
        String result="";
        for (int i=0;i<6;i++)
        {
            result+=random.nextInt(10);
        }
        //System.out.println(result);
        return result;
    }


    public static String getContract_id(){
        return  "H" +getSixNum() + ZOIDGenerate.nextOrderNo();
    }

    public static String getTransaction_id(){
        return "T" +getSixNum() + ZOIDGenerate.nextOrderNo();
    }

}
